#include "task_info_table.h"
#include "sqlite_manager.h"
#include "easylogging++.h"


TaskInfoTable::TaskInfoTable()
{

}

bool TaskInfoTable::updateTaskParentUuid(QString uuid, QString parentUuid)
{
    SqliteManager sm;
    bool ret = sm.updateData("task_info",
                             {
                                 {
                                     "parent_task_uuid", parentUuid
                                 }
                             },
                             {
                                 {
                                     "uuid", uuid
                                 }
                             });
    if (!ret)
    {
        LOG(ERROR) << "update task's parent uuid failed, error info: "
                   << sm.lastError().toStdString();
    }

    return ret;
}

bool TaskInfoTable::updateTaskStatus(QString uuid, QString status)
{
    SqliteManager sm;
    bool ret = sm.updateData("task_info",
                             {
                                 {
                                     "task_status", status
                                 }
                             },
                             {
                                 {
                                     "uuid", uuid
                                 }
                             });
    if (!ret)
    {
        LOG(ERROR) << "update task's status failed, error info: "
                   << sm.lastError().toStdString();
    }

    return ret;
}
